//ST*****************************************复选框*****************************************
function RxCheckBox() {
}

RxCheckBox.init = function (id, checked, value, text, style, callback) {
    var ctrl = document.getElementById(id);
    if (ctrl == undefined || ctrl == null || ctrl == "") {
        ctrl = document.createElement("div");
    }

    ctrl.dispose = RxCommon.dispose;
    ctrl.dispose();

	if (id) {
    	ctrl.id = id;
	}
    ctrl.rxtype = "RxCheckBox";
    ctrl.value = value;
    ctrl.callback = callback;

    if (style) {
        RxCommon.setStyle(ctrl, style);
    }

	ctrl.ce = RxCommon.ce;

    ctrl.label = ctrl.ce(ctrl, "_label_" + id, "div", "rxcheckbox_text");
    ctrl.label.innerHTML = text;
    RxCommon.disableSelection(ctrl.label);

    ctrl.onclick = function() {
        this.checked = !this.checked;
        this.refresh();
        if (this.callback) {
			var rxevent = {};
			rxevent.id = this.id;
			rxevent.name = "click";
			rxevent.self = this._self;
			rxevent.target = this;
			rxevent.source = this;
			rxevent.value = this.value;
			rxevent.checked = this.checked;
	        this.callback(rxevent);
        }
    };

    ctrl.refresh = function() {
        if (this.checked == true) {
            this.className = "rxcheckbox_on";
        } else {
            this.className = "rxcheckbox_off";
        }
    };

    ctrl.checked = (checked==true) ? true : false;
    ctrl.refresh();

    return ctrl;
};
//ED*****************************************复选框*****************************************
